<template>
  <footer class="footer">
    <span class="todo-count"
      >剩余<strong>{{ undoneNum }}</strong></span
    >
    <ul class="filters">
      <li>
        <a
          :class="{ selected: select === 1 }"
          href="javascript:;"
          @click="selectFn(1)"
          >全部</a
        >
      </li>
      <li>
        <a
          :class="{ selected: select === 2 }"
          href="javascript:;"
          @click="selectFn(2)"
          >未完成</a
        >
      </li>
      <li>
        <a
          :class="{ selected: select === 3 }"
          href="javascript:;"
          @click="selectFn(3)"
          >已完成</a
        >
      </li>
    </ul>
    <button class="clear-completed" @click="deleteDone">清除已完成</button>
  </footer>
</template>

<script>
export default {
  computed: {
    undoneNum() {
      return this.$store.getters.undone.length;
    },
    select() {
      return this.$store.state.select;
    },
  },
  methods: {
    selectFn(value) {
      this.$store.commit("SET_SELECT", value);
    },
    deleteDone() {
      this.$store.commit("DELETE_DONE");
    },
  },
};
</script>
